/*
 * Copyright (c) 2023. li.siyuan All rights reserved.
 */

package com.yanfan.attach.domain;

import com.yanfan.common.core.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;


/**
 * id生成策略表
 *
 * @TableName sys_id_strategy
 */
@Getter
@Setter
@ToString
public class SysIdStrategy extends BaseEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 编号长度
     */
    public int NUMBER_LENGTH = 5;
    /**
     * 主键
     */
    private Integer id;
    /**
     * 前缀
     */
    private String prefix;
    /**
     * 日期字符串 yyyyMMdd
     */
    private String dateStr;
    /**
     * 当前编号 00001
     */
    private String number;
    /**
     * 状态（0正常 1关闭）
     */
    private String status;

    public String generate() {
        return prefix + dateStr + number;
    }

    public String formatNumber(int number) {
        return String.format("%0" + NUMBER_LENGTH + "d", number);
    }
}
